<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>

<body>
    <div id="main" v-cloak>
        <com1 :newmsg='msg' @newshow="show"></com1>
    </div>

    <template id="temp">
        <div>
            <h1>子组件内容--{{newmsg}}</h1>
            <input type="button" value="子组件按钮" @click="btn">
        </div>
    </template>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var vm = new Vue({
            el: '#main',
            data: {
                msg: 'Hello Vue1'
            },
            methods: {
                show() {
                    console.log('父组件中的show方法')
                }

            },
            components: {
                com1: {
                    template: '#temp',
                    // props: ['newmsg']
                    props: {
                        newmsg: {
                            type: String
                        }
                    },
                    methods: {
                        btn() {
                            this.$emit('newshow')

                        }
                    }
                }
            }
        })
    </script>

</body>

</html>